<template>
	<view class="content">
		<view class="Popular">
			<view class="pop_content">


				<view class="pop_item" v-for="(item,index) in datalist" :key="index">
					<view class="top">
						<view class="reserveTime">
							<image src="../../../static/icon/icon-dot.png" mode=""></image>
							<text class="reserName">{{item.nickname}}预约了</text>
							<text class="reserTime">{{item.ordertime}}</text>
						</view>
					</view>
					<navigator :url="'/pages/me/content/houseDetail?house_id='+item.house_id" >
					<view class="bottom">					
						<view class="left">
							<!-- {{item.pic}} -->
							<image v-if="item.image" :src="siteUrl+item.image" mode="scaleToFill"></image>
							
							<image v-else :src="siteUrl+item.images.split(',',1)" mode="scaleToFill"></image>
						
						
						</view>
						<view class="right">
							<view class="name">{{item.title}}</view>
							<view class="address">{{item.location_near}}</view>
							<view class="tags">
								<!--	<text class="tag" v-for="(tag,ind) in item.tags" :key="ind">{{tag}}</text>
							-->
							</view>
							<view class="prices">
								<view :class="[item.isActive?'price':'unprice']">{{item.price}}元/月</view>
								<view :style="{display:(item.isActive?'none':'block')}" class="existence">已租</view>
							</view>
						</view>
					</view>
					</navigator>
					<view class="contact" @click="tel(item.mobile)">
						联系他
					</view>
				</view>
				<uni-load-more  :loadingType="loadingType" :contentText="contentText" :status="status"></uni-load-more>	




			</view>
		</view>
	</view>
</template>

<script>
	var _self,
	page = 1,
	timer = null;
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
	export default {
		components: {
		   uniLoadMore
		},
		data() {
			return {
				siteUrl: this.websiteUrl,
				title: 'index',
				datalist: [],
				status: 'more',
				loadingText: '加载中...',
				loadingType: 2,//定义加载方式 0---contentdown  1---contentrefresh 2---contentnomore
				contentText: {
				    contentdown:'上拉显示更多',
				    contentrefresh: '正在加载...',
				    contentnomore: '没有更多数据了'
				}

			}
		},
		onLoad() {
			_self = this
			this.getOrderList()
		},
		onPullDownRefresh: function() {
			//下拉刷新的时候请求一次数据			
		    this.getOrderList()					
		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			//为了更加清楚的看到效果，添加了定时器
		    if (timer != null) {
		        clearTimeout(timer);
		    }		   
			 _self.getmorenews();
		},
		methods: {
			tel($mobile) {
				uni.makePhoneCall({
					phoneNumber: $mobile //仅为示例
				});
			},
			
			getmorenews: function() {
				if(_self.status !== 'more'){
					return false
				}						    
				_self.status = 'loading'
			    uni.showNavigationBarLoading();//显示加载动画
			    uni.request({
			        url:this.websiteUrl+'/api.php/order/orderList?page='+page,
			        method: 'POST',
					header: {
						'content-type':'application/x-www-form-urlencoded'						
					},
					data: {
						token:uni.getStorageSync('token'),						
					},					
			        success: function(res) {			           																	
			            if (res.data.data.data.length == 0) {//没有数据			                
							_self.status = 'noMore'							
			                uni.hideNavigationBarLoading();//关闭加载动画							
			                return false;
			            }
			            page++;//每触底一次 page +1										
			            _self.datalist = _self.datalist.concat(res.data.data.data);//将数据拼接在一起			           
						_self.status = 'more'					
			            uni.hideNavigationBarLoading();//关闭加载动画
			        }
			    });
			},
			
			
			getOrderList() {
				page = 1;
				_self.status = 'more'
				uni.showNavigationBarLoading();					
				uni.request({
					url: this.websiteUrl + '/api.php/order/orderList?page=1',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						token: uni.getStorageSync('token')
					},
					success: function(res) {
						if (res.data.code == 1) {
							page++
							_self.datalist = res.data.data.data	
							uni.hideNavigationBarLoading();
							uni.stopPullDownRefresh();//得到数据后停止下拉刷新						
						}
					},
				});
			}
		}
	}
</script>

<style>
	.content {
		overflow: hidden;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		/* background: #4F5861; */
	}

	.head_button {
		display: flex;
		justify-content: space-between;
		padding: 60upx 0;
		width: 80%;
	}

	.button_item {
		text-align: center;
	}

	.button_item image {
		width: 100upx;
		height: 100upx;
		border-radius: 50%;
	}

	.button_item .button_text {
		color: white;
		font-size: 28upx;
	}

	.Popular {
		width: 100%;
		/* margin-top: -10upx; */
	}

	.pop_title {
		width: 100%;
		height: 90upx;
		text-align: center;
		font-size: 15upx;
		line-height: 90upx;
		background: white;
		border-radius: 10upx 10upx 0 0;
	}

	.pop_content {
		overflow: hidden;
		width: 100%;
		/* background: white; */
	}

	.pop_item {
		width: 700upx;
		margin: 10upx auto;
		padding: 20upx;
		background: #FFFFFF;
	}

	.pop_item .top {
		display: flex;
		justify-content: space-between;
		height: 100upx;
	}

	.pop_item .top .reserveTime {}

	.pop_item .top image {
		width: 20upx;
		height: 20upx;
	}

	.pop_item .top .reserName {
		padding: 0 20upx;
		color: #373737;
		font-size: 28upx;
	}

	.pop_item .top .reserTime {
		color: #373737;
		font-size: 28upx;
	}

	.pop_item .bottom {
		display: flex;
		justify-content: space-between;
		padding-bottom: 20upx;
	}

	.pop_item .bottom .left {
		width: 240upx;
		height: 180upx;
	}

	.pop_item .bottom .left image {
		width: 240upx;
		height: 180upx;
	}

	.pop_item .bottom .left .text {
		font-size: 32upx;
		line-height: 180upx;
	}

	.pop_item .bottom .right {
		width: 440upx;
		height: 200upx;
	}

	.pop_item .bottom .right .name {
		width: 100%;
		height: 40upx;
		font-size: 32upx;
	}

	.pop_item .bottom .right .address {
		width: 100%;
		height: 40upx;
		margin: 10upx 0;
		color: #707071;
		font-size: 24upx;
		line-height: 40upx;
	}

	.pop_item .bottom .right .tags {
		display: flex;
	}

	.pop_item .bottom .right .tag {
		padding: 0 5upx;
		margin: 0 5upx;
		color: #C0C0C0;
		font-size: 24upx;
		border: solid 1px #C0C0C0;
	}

	.pop_item .bottom .right .prices {
		margin-top: 20upx;
		width: 100%;
		display: flex;
		justify-content: space-between;
	}

	.pop_item .bottom .right .prices .price {

		color: #FF4C4C;
		font-size: 30upx;
		line-height: 40upx;
		font-weight: bold;
	}

	.pop_item .bottom .right .prices .unprice {

		color: #999999;
		font-size: 30upx;
		line-height: 40upx;
		font-weight: bold;
	}

	.pop_item .bottom .right .prices .existence {
		width: 60upx;
		height: 30upx;
		background: #CCCCCC;
		color: white;
		font-size: 24upx;
		line-height: 30upx;
		text-align: center;
	}

	.pop_item .contact {
		width: 100%;
		height: 80upx;
		color: #FF984C;
		font-size: 30upx;
		text-align: center;
		line-height: 100upx;
		border-top: solid 1px #EEEEEE;
	}
</style>
